import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ColorVO, ColorForm, ColorQuery } from '@/api/business/color/types';

/**
 * 查询颜色管理列表
 * @param query
 * @returns {*}
 */

export const listColor = (query?: ColorQuery): AxiosPromise<ColorVO[]> => {
  return request({
    url: '/business/color/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询颜色管理详细
 * @param id
 */
export const getColor = (id: string | number): AxiosPromise<ColorVO> => {
  return request({
    url: '/business/color/' + id,
    method: 'get'
  });
};

/**
 * 新增颜色管理
 * @param data
 */
export const addColor = (data: ColorForm) => {
  return request({
    url: '/business/color',
    method: 'post',
    data: data
  });
};

/**
 * 修改颜色管理
 * @param data
 */
export const updateColor = (data: ColorForm) => {
  return request({
    url: '/business/color',
    method: 'put',
    data: data
  });
};

/**
 * 删除颜色管理
 * @param id
 */
export const delColor = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/color/' + id,
    method: 'delete'
  });
};
